<?php
/**
 * Created by PhpStorm.
 * User: THUNDEROBOT
 * Date: 2021/1/10
 * Time: 19:37
 */

namespace app\admin\controller;


use app\admin\model\Student;
use think\Controller;
use think\Request;

class Students extends Controller
{
    public function index(){
        $studentModel = new Student();
        $studentList = $studentModel->student();
//         dump($teacherList->toArray());
        $emptyHtml = '<tr><td align="center" colspan="5">暂无任何数据</td></tr>';
        $this->assign("emptyHtml",$emptyHtml);
        $this->assign("studentList",$studentList);
        return $this->fetch();
    }

    //编辑密码
    public function editstudent(){
        if(Request::instance()->isGet()){
            $id = Request::instance()->get("id");
            $userModel = new Student();
            $Data = $userModel->editstudent($id);
            $this->assign("id",$Data);
            $this->assign("s_username",$Data);
            $this->assign("s_password",$Data);
        }
        return $this->fetch("editstudent");
    }

    //提交编辑密码
    public function doEditstudent(){
        if(Request::instance()->isPost()){
            $userDate = Request::instance()->post();
//            dump($userDate);
            $userModel = new Student();
            $re = $userModel->doEditstudent($userDate);
            if($re){
                $this->success("修改成功",'admin/students/index');
            }else{
                $this->error("修改失败");
            }
        }
    }

}